<?php

/**
 * get all place in Ha Noi
 * 
 **/

//array for JSON response
$response = array();

//include db_connect file
require_once ('db_connect.php');

//connect db
$db = new DB_CONNECT();

//get all place
$query = "SELECT * FROM place";
$result = mysql_query($query) or die(mysql_error());

//check for empty result
if (mysql_num_rows($result) > 0)
{
    //looping through all result
    $response['place'] = array();

    while ($row = mysql_fetch_array($result))
    {
        //temp array
        $place = array();
        $place['lat'] = $row['lat'];
        $place['lang'] = $row['lang'];
        $place['name'] = $row['name_Place'];
        $place['countVote'] = $row['countVote'];
        $place['cat'] = $row['cat'];
        $place['cost'] = $row['cost'];
        $place['location'] = $row['location'];
        $place['diaChi'] = $row['diaChi'];
        $place['moTa'] = $row['moTa'];

        //push data into final response array
        array_push($response['place'], $place);
    }
    //success
    $response['success'] = 1;

    //echo JSON
    echo json_encode($response);
} else
{
    //no place found
    $response['success'] = 0;
    $response['message'] = "no place in DB";

    //echo JSON
    echo json_encode($response);
}

?>